package com.hsj.xiaokang.rewiterequalsandhashcode;
/**
 * 重写equals和hashcode
 * @Description:TODO
 * @author:hsj qq:2356899074
 * @time:2017年11月8日 上午11:19:44
 */
public class Test {
	       private int num;  
	       private String data;  
	   
	       public boolean equals(Object obj)  
	       {  
	           if(this == obj){return true;}  
	                 
	           if((obj == null) || (obj.getClass() != this.getClass())){return false;}  
	          
	          // object must be Test at this point 
	          
	          Test test = (Test)obj;  
	          return num == test.num &&  
	          (data == test.data || (data != null && data.equals(test.data)));  
	       }  
	   
	      public int hashCode()  
	       {  
	          int hash = 7;  
	          hash = 31 * hash + num;  
	          hash = 31 * hash + (null == data ? 0 : data.hashCode());  
	          return hash;  
	       }  
}
